#pragma once
#include "RenderCommon.h"

class COglProgram;

class CRenderContextBase
{
public:
	CRenderContextBase();
	virtual ~CRenderContextBase();

	virtual HRESULT Startup(HWND hPreviewWnd);
	virtual void Shutdown();

	BOOL IsStart() { return m_bStartup; }
	HWND GetPreviewWnd() { return m_hWnd; }
	HDC GetPreviewDC() { return m_hDC; }

	HRESULT SwapBffers();

protected:
	HRESULT Begin();
	HRESULT End();

private:
	BOOL m_bStartup;
	HWND m_hWnd;
	HDC m_hDC;
	HGLRC m_hRC;
};

typedef struct _SRenderVertex
{
	glm::vec4 stPosition;
	glm::vec4 stDiffuse;
}SRenderVertex;

class CRenderContext : public CRenderContextBase
{
public:
	CRenderContext();
	virtual ~CRenderContext();

	virtual HRESULT Startup(HWND hPreviewWnd);
	virtual void Shutdown();

	HRESULT Begin(const glm::mat4& stWorldViewProj);
	HRESULT End();

	int GetPositionAttribLocation() { return m_nPositionAttribLocation; }
	int GetDiffuseAtrribLocation() { return m_nDiffuseAtrribLocation; }

private:
	COglProgram* m_pRenderProgram;
	int m_nPositionAttribLocation;
	int m_nDiffuseAtrribLocation;
};